package com.sense.kukoo.biz_library.adapter

import android.os.Parcelable
import com.sense.kukoo.biz_library.adapter.provider.FollowItemProvider
import com.sense.kukoo.biz_library.adapter.provider.FollowTitleProvider
import com.sense.kukoo.common.media.bean.LocalMediaListItemBean
import com.sense.kukoo.common.media.watcher.UserWatcher
import com.sense.kukoo.common.repo.biz.FollowContentBean
import com.sense.kukoo.common.repo.http.bean.IndexContentBean
import com.sense.kukoo.common.repo.http.bean.UserSearchBean
import com.sense.kukoo.common.wiget.adapter.MultiItemAdapter
import com.sense.kukoo.common.wiget.adapter.viewholder.BaseViewHolder


class FollowAdapter(

    val data:List<FollowContentBean>,
    val listener:FollowContentEventListener,

): MultiItemAdapter<FollowContentBean>(data) {

    private val TAG: String = javaClass.simpleName

    var mCurrentMusic: LocalMediaListItemBean? = null
    var mCurrentPlayState: Int = UserWatcher.MusicStateWatcher.STATE_NOT_PLAYING

    val mFollowItemProvider: FollowItemProvider = FollowItemProvider(listener)
    val mFollowTitleProvider: FollowTitleProvider = FollowTitleProvider(listener)

    init {
        addItemProvider(mFollowItemProvider)
        addItemProvider(mFollowTitleProvider)
    }

    override fun getItemType(data: MutableList<FollowContentBean>, position: Int): Int {
        return data.get(position).type
    }

    interface FollowContentEventListener{
        fun onItemClick(data: IndexContentBean)
        fun onChannelClick(data: IndexContentBean)
        fun onBtnPlayClick(data: IndexContentBean)
        fun onTitleChannelClick(data: FollowContentBean)
        fun onTitleItemClick(user: UserSearchBean)
    }

    fun setCurrentMusic(music: LocalMediaListItemBean){
        mCurrentMusic = music
        //
        mFollowItemProvider.setCurrentMusic(music)
        notifyDataSetChanged()
    }

    fun setCurrentPlayState(state: Int){
        mCurrentPlayState = state
        //
        mFollowItemProvider.setCurrentPlayState(state)
        notifyDataSetChanged()
    }
}